package com.argrace.smart.adapter;

import android.content.Context;
import android.view.View;
import android.widget.ImageView;

import com.argrace.smart.R;
import com.argrace.smart.entity.ZigBeeDeviceEntity;
import com.argrace.smart.glide.GliderImageLoaderUtil;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;

import java.util.ArrayList;

/**
 * Created by argrace_dev_1 on 2018/2/2.
 */

public class MyZigBeeDeviceAdapter extends BaseQuickAdapter<ZigBeeDeviceEntity, BaseViewHolder> {
    private Context context;

    public MyZigBeeDeviceAdapter(ArrayList<ZigBeeDeviceEntity> data, Context context) {
        super(R.layout.item_activity_main_device, data);
        this.context = context;
    }

    @Override
    protected void convert(BaseViewHolder baseViewHolder, final ZigBeeDeviceEntity item, final int position) {
//        ImageView img = baseViewHolder.getView(R.id.item_activity_main_device_img);
        baseViewHolder.setText(R.id.item_activity_main_device_name, item.getName());
        baseViewHolder.setText(R.id.item_activity_main_device_macaddr, item.getModel());
        baseViewHolder.getView(R.id.item_activity_main_device_ll).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (listener != null) {
                    listener.click(item, position);
                }
            }
        });
        baseViewHolder.getView(R.id.item_activity_main_device_ll).setOnLongClickListener(new View.OnLongClickListener() {
            @Override
            public boolean onLongClick(View v) {
                if (longlistener != null) {
                    longlistener.click(item, position);
                }
                return true;
            }
        });
    }

    private ZigBeeDeviceAdapter.OnAdapterItemClickListener listener;

    public interface OnAdapterItemClickListener {
        void click(ZigBeeDeviceEntity bean, int position);
    }

    public void setListeners(ZigBeeDeviceAdapter.OnAdapterItemClickListener l) {
        this.listener = l;
    }

    private ZigBeeDeviceAdapter.OnAdapterItemLongClickListener longlistener;

    public interface OnAdapterItemLongClickListener {
        void click(ZigBeeDeviceEntity bean, int position);
    }

    public void setlongListeners(ZigBeeDeviceAdapter.OnAdapterItemLongClickListener l) {
        this.longlistener = l;
    }


}


